﻿    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Caterer.aspx.cs" Inherits="WebApplication1.Caterer" MasterPageFile="~/masterpage/User.Master" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">

    <%--Begin Loading ajax section--%>
    <asp:ScriptManager ID="ScriptManager1"  runat="server">
    </asp:ScriptManager>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
            <div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
                <div class="center">
                   
                    <img alt="" src="images/loading.gif" />
                </div>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
     <%--End Loading ajax section--%>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       
        <ContentTemplate>
            <div class="container-fluid">

                <fieldset>
                    <legend>Search Food</legend>
                </fieldset>
                <div class="control-group col-md-8">

                    <label class="control-label">Site:</label>
                    <div class="controls">
                        <asp:DropDownList ID="dropdownSite" runat="server" class="form-control" AutoPostBack="True" OnSelectedIndexChanged="dropdownSite_SelectedIndexChanged" AppendDataBoundItems="true">
                            <asp:ListItem Text="--Select Site--" Value="0"></asp:ListItem>
                        </asp:DropDownList>

                    </div>

                    <label class="control-label">Cafe :</label>
                    <div class="controls">
                        <asp:DropDownList ID="dropdownCaterer" runat="server" class="form-control" AutoPostBack="True" AppendDataBoundItems="true">
                            <asp:ListItem Text="--Select Cafe--" Value="0"></asp:ListItem>
                        </asp:DropDownList>
                    </div>

                    <div class="control-group">
                        <label class="control-label"></label>
                        <div class="controls">

                            <asp:Button ID="btnSearch" runat="server" class="btn  btn-primary" Text="Search Food" OnClick="btnSearch_Click" />
                        </div>
                    </div>


                    <br />
                    <fieldset>
                        <legend>Food List</legend>
                    </fieldset>
                    <div class="row">
                        <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
                            <ItemTemplate>
                                <div id='<%# "Panel"+ Eval("Id")%>' class="col-sm-4 col-lg-4 col-md-4 corner">
                                    <h2 id='<%# "H2"+ Eval("Id")%>'><%#Eval("isPromotion").ToString() =="1" ? "Promotion": "0" %></h2>
                                    <div class="thumbnail">
                                        <img alt="" src='<%#  "GetImage.aspx?id=" +  Eval("Id") %>' />
                                        <%--  <asp:Image ID="Image1" ImageUrl='<%#  "GetImage.aspx?id=" +  Eval("Id") %>' runat="server"  EnableViewState="false"/>--%>
                                        <%--  <img src="http://placehold.it/320x150" alt="">--%>
                                        <div class="caption">

                                            <h4><b><%# Eval("FoodName")%> </b>
                                            </h4>
                                            <h4 <%--class="pull-right"--%>>RM<%# Eval("isPromotion").ToString() =="1" ? Eval("PromotionPrice") + "(" + Eval("FoodPrice") + ")" :Eval("FoodPrice") %></h4>

                                            <p><%# Eval("FoodDescription")%></a>.</p>
                                        </div>
                                        <div id="order">
                                            <!-- Order modal -->
                                            <a href="#" class="btn btn-lg btn-primary center-block" data-toggle="modal" data-target="<%# "#basicModal"+ Eval("Id")%>">Order</a>

                                            <div class="modal fade" id="<%# "basicModal"+ Eval("Id")%>" tabindex="-1" role="dialog" aria-labelledby="<%# "basicModal"+ Eval("Id")%>" aria-hidden="true">
                                                <div class="modal-dialog">
                                                    <div class="modal-content">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                                                            <h4 class="modal-title" id="myModalLabel">Order</h4>
                                                        </div>
                                                        <div class="modal-body">
                                                            <label class="control-label">Quantity:</label>
                                                            <div class="controls">
                                                                <asp:TextBox ID="txtQuantity" runat="server" class="form-control" ToolTip="Item quantity" maxlength="10" onkeypress="return validatenumerics(event)"></asp:TextBox>

                                                                <%--   <asp:TextBox" runat="server" ID="txtQuantity"  class="form-control"></asp:TextBox>--%>
                                                            </div>
                                                            <label class="control-label">Condiment:</label>
                                                            <div class="controls">
                                                                <asp:TextBox ID="txtCondiment" runat="server" class="form-control" ToolTip="Remark for the ordered food" MaxLength="199"></asp:TextBox>

                                                                <%--   <asp:TextBox" runat="server" ID="txtQuantity"  class="form-control"></asp:TextBox>--%>
                                                            </div>
                                                        </div>
                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                                            <asp:Button runat="server" class="btn btn-primary" Text="Add Items" ID="btnAddItem" OnClick="btnAddItem_Click" CommandArgument='<%# Eval("Id")%> ' OnClientClick="$('.modal-backdrop').remove();"></asp:Button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </ItemTemplate>
                        </asp:Repeater>



                    </div>
                </div>

                <div class="control-group col-md-4 container">

                    <div id="cart">
                        <h3>My Order</h3>

                        <div id="cart_amount">
                            <asp:ListView ID="lsvCart" runat="server" OnItemDataBound="lsvCart_DataBound" OnPreRender="lsvCart_PreRender" OnItemCommand="lsvCart_ItemCommand">
                                <EmptyDataTemplate>
                                    None
                                </EmptyDataTemplate>
                                <LayoutTemplate>
                                    <table id="itemPlaceholderContainer" runat="server" border="0" style="" class="table table-hover table-bordered">
                                        <tr runat="server" class="info">

                                            <th runat="server">Food    
                                        <asp:Label ID="lblName" runat="server" Text=""></asp:Label></th>

                                            <th runat="server">Price</th>
                                            <th runat="server">Quantity</th>
                                            <th runat="server"></th>

                                        </tr>
                                        <tr id="itemPlaceholder" runat="server">
                                        </tr>
                                        <tr runat="server">
                                            <td colspan="2">
                                                <b>Total</b>
                                            </td>
                                            <td colspan="2">
                                                <asp:Label runat="server" ID="lblTotal" Text=""></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                </LayoutTemplate>

                                <ItemTemplate>
                                    <tr style="">
                                        <td>
                                            <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>' />
                                        </td>
                                        <td>
                                            <asp:Label ID="lblPrice" runat="server" Text='<%# Eval("Price") %>' />
                                        </td>
                                        <td>
                                            <asp:Label ID="lblQuantity" runat="server" Text='<%# Eval("Quantity") %>' />
                                        </td>
                                        <td>
                                            <asp:LinkButton ID="btnDelete" runat="server" CommandArgument='<%# Eval("FoodId") %>'>[x]</asp:LinkButton>


                                        </td>
                                </ItemTemplate>
                            </asp:ListView>
                        </div>


                        <div id="cartaction">
                            <a href="Checkout.aspx" id="body_btnCheckout" class="btn btn-primary">Checkout </a>
                            <asp:Button runat="server" ID="btnClear" Text="Clear" class="btn btn-primary" OnClick="btnClear_Click" />
                        </div>
                    </div>
                </div>

            </div>

            <script>
                //$(document).ready()
                //{
                //    var div = $("h2:contains('0')").parent();
                //    div.removeClass("corner");
                //    div.addClass("Nocorner")
                //    div.find("h2").remove();


                //}
            </script>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

